package com.book.modules.core.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

/**
 * Description：
 * @Author： leo.xiong
 * @CreateDate： 2019/10/14 10:44
 * @Email： leo.xiong@suyun360.com
 * Version：1.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class DataEntity<T> extends BaseEntity<T> implements Serializable {

    private static final long serialVersionUID = -1L;

    @TableField("remarks")
    @Size(max = 500, message = "{noMoreThan}")
    protected String remarks;

    @TableField(value = "create_by", fill = FieldFill.INSERT)
    protected String createBy;

    @TableField(value = "create_name", fill = FieldFill.INSERT)
    protected String createName;

    @TableField(value = "create_date", fill = FieldFill.INSERT)
    protected Date createDate;

    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    protected String updateBy;

    @TableField(value = "update_name", fill = FieldFill.INSERT_UPDATE)
    protected String updateName;

    @TableField(value = "update_date", fill = FieldFill.INSERT_UPDATE)
    protected Date updateDate;
    /**
     * 数据状态（0：正常，1：删除，2：审核，3：冻结）
     * 逻辑删除
     */
    @TableField("status")
    @NotBlank(message = "{required}")
    @TableLogic
    protected Integer status;

    /**
     * 乐观锁
     */
    @Version
    @TableField("version")
    private Integer version;

    public DataEntity() {
        super();
        this.status = BaseEntity.STATUS_NORMAL;
    }
}
